home *** CD-ROM | disk | FTP | other *** search
- ;******************************************
- ;* T E D I T M A N A G E R *
- ;******************************************
-
-
- INCLUDE Library.Txt
-
- ;-------------------------------
- ; *** External Definition ***
- ;-------------------------------
-
- XDEF InstalText
- XDEF FindText
- XDEF DrawTexts
- XDEF DeactivateText
- XDEF ActivateText
-
- ;-------------------------------
- ;******* Text Record *********
- ;-------------------------------
-
- ;TERec = Record {100 bytes}
- ;{ 0} destRect : Rect
- ;{ 8} viewRect : Rect
- ;{ 16} selRect : Rect
- ;{ 24} lineHeight : -1
- ;{ 26} fontAscent : -1
- ;{ 28} selPoint : Point
- ;{ 32} selStart : INTEGER
- ;{ 34} selEnd : INTEGER
- ;{ 36} active : INTEGER
- ;{ 38} wordBreak : ProcPtr
- ;{ 42} clikLoop : ProcPtr
- ;{ 46} clickTime : LongInt
- ;{ 50} clickLoc : INTEGER
- ;{ 52} caretTime : LongInt
- ;{ 56} caretState : INTEGER
- ;{ 58} just : INTEGER
- ;{ 60} TELength : INTEGER
- ;{ 62} hText : Handle
- ;{ 66} recalBack : INTEGER
- ;{ 68} recalLines : INTEGER
- ;{ 70} clikStuff : INTEGER
- ;{ 72} crOnly : INTEGER
- ;{ 74} txFont : 1/2 Handle
- ;{ 76} txFace : 1/2 Handle
- ;{ 78} txMode : XferMode
- ;{ 80} txSize : -1
- ;{ 82} inPort : GrafPtr
- ;{ 86} highHook : ProcPtr
- ;{ 90} caretHook : ProcPtr
- ;{ 94} nLines : INTEGER
- ;{ 96} lineStarts : Array[0:1] of INTEGER
-
- ;-------------------------------
- ; ***** Text AuxRecord ********
- ;-------------------------------
-
- ;TEAuxRec = Record {12 bytes}
- ;{0} TID :INTEGER
- ;{2} theText :TEHandle
- ;{6} nextText :TEAuxHandle
-
- ;---------------------------------------------------------------------------
- ;FUNCTION InstalText(textID:INTEGER;whichWindow:WindowPtr):OSErr;
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- textID EQU 12
- whichWindow EQU 8
-
- ;-------------------------------
- ; Local Variables
- ;-------------------------------
-
- theHandle EQU -10
- theNText EQU -6
- error EQU -2
-
- ;-------------------------------
-
- InstalText
- LINK A6,#-10 ;local space
- MOVEM.L A2-A4/D3-D7,-(SP) ;save registers
- MOVE.W noErr,error(A6) ;
- SUBQ.L #4,SP ;space for result
- MOVE.L #'TEHD',-(SP) ;restype is'TEHD'
- MOVE.W textID(A6),-(SP) ;res ID
- _GetResource ;
- MOVEA.L (SP)+,A1 ;
- SUBQ.L #2,SP ;
- _ResError ;check for error
- MOVE.W (SP)+,error(A6) ;
- BNE @0 ;
- MOVE.L A1,theHandle(A6) ;save handle
- MOVEA.L (A1),A1 ;
- SUBQ.L #4,SP ;space for TEHandle
- PEA teDestRect(A1) ;
- PEA teViewRect(A1) ;
- _TEStylNew ;
- MOVEA.L (SP),A1 ;TEHandle in A1
- MOVE.L A1,theNText(A6) ;save it
- _TECalText ;Tech Note #131
- MOVE.L theNText(A6),A1 ;
- MOVE.L (A1),A1 ;
- MOVE.L whichWindow(A6),teGrafPort(A1);
- MOVE.W #TRUE,-(SP) ;
- MOVE.L theNText(A6),-(SP) ;
- _TEAutoView ;
- MOVE.L whichWindow(A6),A0;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L WText(A0),A3 ;
- MOVEA.L (A3),A3 ;
- CMPI.L #NIL,theText(A3) ;is there any text ?
- BEQ @2 ;no, so add one
-
- @4
- CMPI.L #NIL,nextText(A3);another text after ?
- BEQ @3 ;no,add one (@3)
- MOVEA.L nextText(A3),A3 ;go to the next one
- MOVEA.L (A3),A3 ;
- BRA @4 ;
-
- @3
- MOVEQ #SizeTEAuxRec,D0 ;storage for new textAuxRec
- _NewHandle ;
- MOVE.W D0,error(A6) ;
- BNE @1 ;if error go @1
- MOVE.L A0,nextText(A3) ;
- MOVEA.L A0,A3 ;
- MOVEA.L (A3),A3 ;
- MOVE.L theNText(A6),theText(A3);
- MOVE.L #NIL,nextText(A3);
- MOVE.W textID(A6),TID(A3);
- BRA @0 ;
-
- @2
- MOVE.L theNText(A6),theText(A3);for the first
- MOVE.L #NIL,nextText(A3) ;text of the list
- MOVE.W textID(A6),TID(A3) ; TEAuxRec already
- BRA @0 ;exists
-
- @1
- MOVE.L theNText(A6),-(SP) ;we can't allocate
- _TEDispose ;space for TEAuxRec
- @0
- MOVE.W error(A6),D0 ;
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;get return address
- ADD.L #6,SP ;clean up the stack
- MOVE.W D0,(SP) ;push function result
- JMP (A0) ;
-
- ;---------------------------------------------------------------------------
- ;FUNCTION FindText(thePoint:Point;whichWindow:WindowPtr):TEHandle;
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- thePoint EQU 12
-
- ;-------------------------------
- ; Variables
- ;-------------------------------
-
- SauvHdl EQU -4
-
- ;-------------------------------
-
- FindText
- LINK A6,#-4 ;
- MOVEM.L A2-A4/D3-D7,-(SP);
- MOVE.L #NIL,A1 ;
- MOVE.L whichWindow(A6),A0;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L WText(A0),A3 ;begining
- MOVE.L A3,SauvHdl(A6) ;of text list
- MOVEA.L (A3),A3 ;saved on stack
- CMPI.L #NIL,theText(A3) ;is there any text?
- BEQ @0 ;no,so go away
- @3
- MOVEA.L theText(A3),A2 ;
- MOVEA.L (A2),A2 ;
- SUBQ.L #2,SP ;
- MOVE.L thePoint(A6),-(SP);do we
- PEA teViewRect(A2) ;click in
- _PtInRect ;this one ?
- MOVE.L SauvHdl(A6),A3 ;
- MOVE.L (A3),A3 ;
- TST.B (SP)+ ;
- BNE @1 ;yes ! go @1
- CMPI.L #NIL,nextText(A3) ;no.
- BEQ @0 ;if no more texts
- MOVEA.L nextText(A3),A3 ;go @0 ,if not...
- MOVE.L A3,SauvHdl(A6) ;next one !
- MOVEA.L (A3),A3 ;
- BRA @3 ;
- @1
- MOVE.L theText(A3),A1 ;"clicked" TEHandle
- @0 ;in A1
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #8,SP ;
- MOVE.L A1,(SP) ;
- JMP (A0) ;
-
- ;---------------------------------------------------------------------------
- ;PROCEDURE DrawTexts(whichWindow:WindowPtr);
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; Local Variables
- ;-------------------------------
-
- TextAuxHdl EQU -4
-
- ;-------------------------------
-
- DrawTexts
- LINK A6,#-4 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L whichWindow(A6),A0 ;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L WText(A0),A3 ;
- MOVE.L A3,TextAuxHdl(A6) ;
- MOVE.L (A3),A3 ;
- CMPI.L #NIL,theText(A3) ;is there text in
- BEQ @0 ;the window ?
- @3
- MOVEA.L theText(A3),A0 ;
- MOVEA.L (A0),A0 ;
- PEA teViewRect(A0) ;
- MOVE.L theText(A3),-(SP) ;
- _TEUpdate ;draw texts
- MOVE.L TextAuxHdl(A6),A3 ;
- MOVE.L (A3),A3 ;
- CMPI.L #NIL,nextText(A3) ;until no more
- BEQ @0 ;texts in list
- MOVEA.L nextText(A3),A3 ;
- MOVE.L A3,TextAuxHdl(A6) ;
- MOVEA.L (A3),A3 ;
- BRA @3 ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;no more
- UNLK A6 ;texts
- MOVE.L (SP)+,A0 ;go away.
- ADD.L #4,SP ;
- JMP (A0) ;
-
- ;---------------------------------------------------------------------------
- ;PROCEDURE DeactivateText(whichWindow:WindowPtr);
- ;---------------------------------------------------------------------------
-
- DeactivateText
- LINK A6,#0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVEA.L whichWindow(A6),A1 ;
- MOVE.L WRefCon(A1),A1 ;
- MOVE.L (A1),A1 ;
- MOVE.L WactivTxt(A1),A1 ;
- MOVE.L A1,CurrentText(A5) ;
- CMPA.L #NIL,A1 ;
- BEQ @0 ;
- MOVE.L A1,-(SP) ;
- _TEDeactivate ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #4,SP ;
- JMP (A0) ;
-
- ;---------------------------------------------------------------------------
- ;PROCEDURE ActivateText(whichWindow:WindowPtr);
- ;---------------------------------------------------------------------------
-
- ActivateText
- LINK A6,#0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVEA.L whichWindow(A6),A1 ;
- MOVE.L WRefCon(A1),A1 ;
- MOVE.L (A1),A1 ;
- MOVE.L WactivTxt(A1),A1 ;
- MOVE.L A1,CurrentText(A5) ;
- CMPA.L #NIL,A1 ;
- BEQ @0 ;
- MOVE.L A1,-(SP) ;
- _TEActivate ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #4,SP ;
- JMP (A0) ;
-
-
- END